package com.Producer;

import com.constant.TopicConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class RedisCacheProducer {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;


    /**
     * 发送缓存数据到 Kafka
     */
    public void maintenanceManSendToKafka(String key, String value) {

        kafkaTemplate.send(TopicConstant.MAIN_CACHE_TOPIC, key, value);

        log.info("消息发送到 Kafka:{}，{} -> {}",TopicConstant.MAIN_CACHE_TOPIC,key,value);

    }

    /**
     * 发送缓存数据到 Kafka
     */
    public void adminSendToKafka(String key, String value) {

        kafkaTemplate.send(TopicConstant.ADMIN_CACHE_TOPIC, key, value);

        log.info("消息发送到 Kafka:{}，{} -> {}",TopicConstant.ADMIN_CACHE_TOPIC,key,value);

    }



}
